import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:lesson_0911/CustomData.dart';

class SelfGridView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List _imglist = CustomData().imgList;
    return Scaffold(
      appBar: AppBar(
        title: Text('精选 海报'),
      ),

      // body: GridView(
      //   gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
      //     crossAxisCount: 3,
      //     mainAxisSpacing: 2,
      //     crossAxisSpacing: 2,
      //     childAspectRatio: 0.7
      //   ),
      //   children: <Widget>[
      //     Image(image: NetworkImage(_imglist[0]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[1]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[2]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[3]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[4]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[5]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[6]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[7]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[8]), fit: BoxFit.cover,),
      //   ],
      // ),


      // body: GridView.count(
      //   crossAxisCount: 3,
      //   mainAxisSpacing: 2,
      //   crossAxisSpacing: 2,
      //   childAspectRatio: 0.7,
      //   children: <Widget>[
      //     Image(image: NetworkImage(_imglist[0]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[1]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[2]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[3]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[4]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[5]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[6]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[7]), fit: BoxFit.cover,),
      //     Image(image: NetworkImage(_imglist[8]), fit: BoxFit.cover,),
      //   ],
      // ),


      body: GridView.builder(
        itemCount: _imglist.length,
        itemBuilder: (BuildContext context, int i){
          return Image(image: NetworkImage(_imglist[i]), fit: BoxFit.cover);
        },
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          crossAxisSpacing: 2,
          mainAxisSpacing: 2,
          childAspectRatio: 0.7
        ),
      ),


    );
  }
}
